/*******************************************************************************
generate coefficient plots of the falsification tests
*******************************************************************************/

clear all
set matsize 800
set more off


use "${datapath}/fascism_db.dta",clear

* standardize dependent and independent vars
foreach var of varlist fascist_violence-strike_agr_1920 lpop1911-volunteers1866_pop rain1918-rain_var {
egen z_`var'=std(`var')
drop `var'
}

* relabel them
run "labels.do"

*******************************************************************************
*******************************************************************************
*******************************************************************************

eststo clear

****CONTROLS
local demo "z_lpop1911 z_lpop2 z_lpop3 z_lpop4 z_sh_pop_1911_be6"
local geo "z_larea z_centre_alt z_max_alt"
local rural "z_dlab z_shcrop z_landlord_ass"
local urban "z_ind_workers z_ind_firms z_literacy z_elites z_bourgeoisie"
local urban_literacy "z_ind_workers z_ind_firms z_elites z_bourgeoisie"
local urban_ind_firms "z_ind_workers z_literacy z_elites z_bourgeoisie"
local urban_ind_workers "z_ind_firms z_literacy z_elites z_bourgeoisie"
local corps "z_ard_vol_pop6m z_cruent_d z_veterans74_95 z_veterans96_00 z_army_suppliers_d"
local corps_no_ard "z_volunt_pop6m z_cruent_d z_veterans74_95 z_veterans96_00 z_army_suppliers_d"
local corps_no_vol "z_arditi_pop6m z_cruent_d z_veterans74_95 z_veterans96_00 z_army_suppliers_d"
local corps_no_ard_vol_pop6m "z_cruent_d z_veterans74_95 z_veterans96_00 z_army_suppliers"
*****

eststo clear

*** first stage
eststo fs_1: qui reg z_psu1919_vv z_foots_pop6m `demo' d_reg* province* , cl(circondario1921)
eststo fs_2: qui reg z_psu1919_vv z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' d_reg* province* , cl(circondario1921)
eststo fs_3: qui reg z_psu1919_vv z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' `rural' `urban' d_reg* province* , cl(circondario1921)
***psu1913_vv
eststo soc_1: qui reg z_psu1913_vv z_foots_pop6m `demo' d_reg* province* , cl(circondario1921)
eststo soc_2: qui reg z_psu1913_vv z_foots_pop6m `demo' `geo' `corps' d_reg* province* , cl(circondario1921)
eststo soc_3: qui reg z_psu1913_vv z_foots_pop6m `demo' `geo' `corps' `rural' `urban' d_reg* province* , cl(circondario1921)
***literacy
eststo lit_1: qui reg z_literacy z_foots_pop6m `demo' d_reg* province* , cl(circondario1921)
eststo lit_2: qui reg z_literacy z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' d_reg* province* , cl(circondario1921)
eststo lit_3: qui reg z_literacy z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' `rural' `urban_literacy' d_reg* province*  , cl(circondario1921)
***crime
foreach v in viol_crimes1874 crime1874 {
eststo `v'_1: qui reg z_`v' z_foots_pop6m `demo' d_reg* province* , cl(circondario1921)
eststo `v'_2: qui reg z_`v' z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' d_reg* province* , cl(circondario1921)
eststo `v'_3: qui reg z_`v' z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' `rural' `urban' d_reg* province* , cl(circondario1921)
}
***ind_workers
eststo indw_1: qui reg z_ind_workers z_foots_pop6m `demo' d_reg* province* , cl(circondario1921)
eststo indw_2: qui reg z_ind_workers z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' d_reg* province* , cl(circondario1921)
eststo indw_3: qui reg z_ind_workers z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' `rural' `urban_ind_workers' d_reg* province* , cl(circondario1921)
***ind_firms
eststo indf_1: qui reg z_ind_firms z_foots_pop6m `demo' d_reg* province* , cl(circondario1921)
eststo indf_2: qui reg z_ind_firms z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' d_reg* province* , cl(circondario1921)
eststo indf_3: qui reg z_ind_firms z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' `rural' `urban_ind_firms' d_reg* province* , cl(circondario1921)
*** strikes
foreach v in indstrike1913_4 indstrikers1913_4 {
eststo `v'_1: qui reg z_`v' z_foots_pop6m `demo' d_reg* province* , cl(circondario1921)
eststo `v'_2: qui reg z_`v' z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' d_reg* province* , cl(circondario1921)
eststo `v'_3: qui reg z_`v' z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' `rural' `urban' d_reg* province* , cl(circondario1921)
}
*** owners and agr strikes
foreach v in mlarge1885 ownfarm_lots1885 agrstrike1913_4 agrstrikers1913_4 {
eststo `v'_1: qui reg z_`v' z_foots_pop6m `demo' d_reg* province* , cl(circondario1921)
eststo `v'_2: qui reg z_`v' z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' d_reg* province* , cl(circondario1921)
eststo `v'_3: qui reg z_`v' z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' `rural' `urban' d_reg* province* , cl(circondario1921)
}
**** volunteers / mutue
foreach v in volunteers1866_pop volunteers1866d ass_memb1900s_pop ass1900s_d {
eststo `v'_1: qui reg z_`v' z_foots_pop6m `demo' d_reg* province* , cl(circondario1921)
eststo `v'_2: qui reg z_`v' z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' d_reg* province* , cl(circondario1921)
eststo `v'_3: qui reg z_`v' z_foots_pop6m `demo' `geo' z_psu1913_vv `corps' `rural' `urban' d_reg* province* , cl(circondario1921)
}
*

#delim ;

coefplot 	fs_1 fs_2 fs_3,													bylabel(Socialists 1919 (First Stage)) ||
			soc_1 soc_2 soc_3, 												bylabel(Socialists 1913) ||
			lit_1 lit_2 lit_3, 												bylabel(Literacy 1911) ||
			viol_crimes1874_1 viol_crimes1874_2 viol_crimes1874_3, 			bylabel(Violent Crimes 1874) ||
			crime1874_1 crime1874_2 crime1874_3, 							bylabel(Crime Rate 1874) ||
			indw_1 indw_2 indw_3, 											bylabel(Ind. Workers 1911) ||
			indf_1 indf_2 indf_3, 											bylabel(Ind. Firms 1911) ||
			indstrike1913_4_1 indstrike1913_4_2 indstrike1913_4_3, 			bylabel(Ind. Strikes 1913-4) ||
			indstrikers1913_4_1 indstrikers1913_4_2 indstrikers1913_4_3, 	bylabel(Ind. Strikers 1913-4) ||
			mlarge1885_1 mlarge1885_2 mlarge1885_3, 						bylabel(Large Landholding 1885) ||
			ownfarm_lots1885_1 ownfarm_lots1885_2 ownfarm_lots1885_3, 		bylabel(Landownership 1885) ||
			agrstrike1913_4_1 agrstrike1913_4_2 agrstrike1913_4_3, 			bylabel(Agr. Strikes 1913-4) ||
			agrstrikers1913_4_1 agrstrikers1913_4_2 agrstrikers1913_4_3, 	bylabel(Agr. Strikers 1913-4) ||
			volunteers1866_pop_1 volunteers1866_pop_2 volunteers1866_pop_3, bylabel(Volunteers in 1866) ||
			volunteers1866d_1 volunteers1866d_2 volunteers1866d_3, 			bylabel(Volunteers in 1866 (Binary)) || 
			ass_memb1900s_pop_1 ass_memb1900s_pop_2 ass_memb1900s_pop_3, 	bylabel(Assoc. Members in 1900s) ||
			ass1900s_d_1 ass1900s_d_2 ass1900s_d_3, 						bylabel(Associations in 1900s (Binary)) ||,
			bycoefs plotlabels("1st Specification" "4th Specification" "6th Specification") keep(z_foots_pop6m) xline(0) msymbol(s) msize(vsmall) ci(95) ciopts(recast(rcap))  plotregion(color(white)) xlabel(, nogrid) ylabel(, labsize(small)) xtitle(, size(small)) xscale(lcolor("black") fextend) yscale(lcolor("black")  fextend)   ysize(8) legend(off); 
		
#delim cr

graph export "${outpath}/fig3.png", replace width(4000)
